<%@page import="com.pizzaria.util.Util"%>
<%@page import="com.pizzaria.bean.ClienteDAO"%>
<%@page import="com.pizzaria.bean.Cliente"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8"/>
    <title>Pizzaria</title>
    <link href="style.css" rel="stylesheet"/>
    <link href="script/ui/css/ui-lightness/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
    <script src="script/ui/jquery-1.7.2.min.js"></script>
    <script src="script/ui/jquery-ui-1.8.20.custom.min.js"></script>
    <script src="script/util.js"></script>
  </head>
  <body>
      <%
      	String id = request.getParameter("id");
      
      	Cliente cli = null;
      	if(id != null) cli = ClienteDAO.get(Long.parseLong(id));
      %>
  	<div id="top">
		<h1>Pizzaria</h1>
	</div>
	<div id="left">
		<div id="menu">
			<a href="list.jsp?type=func">Funcionário</a>
			<a href="list.jsp?type=cli">Cliente</a>
			<a href="list.jsp?type=ped">Pedido</a>
			<a href="list.jsp?type=prod">Produto</a>
		</div>
	</div>
	<div id="conteudo">
		<div id="path">Pedido > <%= cli == null ? "Novo" : "Editar" %> ></div>
		<div id="content">
           <h2>Cliente</h2>
         <form id="frmCli" action="javascript: actionSend('rest/crud/cliente', 'frmCli');" method="POST">
           <label>Código</label>
	   <input id="txtCod" name="txtCod" type="text" value="<%= cli == null ? "" : cli.getId() %>" readonly="true"/>
	   
	   <fieldset>
	      <legend>Informações Pessoais</legend>
	      <label>Nome</label>
	      <input id="txtNome" name="txtNome" type="text" value="<%= cli == null ? "" : cli.getNome() %>" required/>
	      <label>CPF</label>
	      <input id="txtCPF" name="txtCPF" type="text" value="<%= cli == null ? "" : cli.getCpf() %>" pattern="[0-9]{3}\.[0-9]{3}\.[0-9]{3}-[0-9]{2}" placeholder="333.354.789-73" required/>
	      <label>Dt Nasc.</label>
	      <input id="txtNasc" name="txtNasc" type="date" value="<%= cli == null ? "" : Util.formatDate(cli.getDtNasc()) %>" pattern="[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}" placeholder="05/04/1981" required/>
           </fieldset>
           
           <fieldset>
	      <legend>Informações para contato</legend>
	      <label>Telefone</label>
	      <input id="txtTel" name="txtTel" type="tel" value="<%= cli == null ? "" : cli.getTelefone() %>" placeholder="(45) 4568-3897"/>
	      <label>Celular</label>
	      <input id="txtCel" name="txtCel" type="tel" value="<%= cli == null ? "" : cli.getCelular() %>" placeholder="(45) 4568-3897"/>
	      <label>Operadora</label>
	      <input id="txtOperadora" name="txtOperadora" type="text" list="operadora" value="<%= cli == null ? "" : cli.getOperadora() %>" >
	      <datalist id="operadora" >
			<option> Claro
			<option> Tim
			<option> Vivo
			<option> Oi
			<option> Livre
	      </datalist>
	      <label>Endereço</label>
	      <input id="txtEnd" name="txtEnd" type="text" value="<%= cli == null ? "" : cli.getEndereco() %>" required/>
	      <label>Número</label>
	      <input id="txtNum" name="txtNum" type="text" value="<%= cli == null ? "" : cli.getNumero() %>" required/>
	      <label>Compl.</label>
	      <input id="txtComp" name="txtComp" type="text" value="<%= cli == null ? "" : cli.getCompl() %>"/>
	      <label>CEP</label>
	      <input id="txtCEP" name="txtCEP" type="text" placeholder="10369-789" value="<%= cli == null ? "" : cli.getCep() %>" required/>
	      <label>Cidade</label>
	      <input id="txtCidade" name="txtCidade" type="text" value="<%= cli == null ? "" : cli.getCidade() %>" required/>
           </fieldset>
           <div id="pnl-button">
           		<input name="" type="submit" value="Salvar"/>
           </div>
         </form>
      </div>
      </div>
  </body>
</html>